import pandas as pd
import numpy as np
import datetime

score = [0.87826, 0.87829, 0.87663,
         # 0.87029,
         0.872]
stra = ['res_lgb300per_20200205_175908-0.87826', 'res_lgb300per_20200205_161940-0.87829',
        'res_lgb_mer200_per_20200208_011324-0.87663',
        # 'res_lgb_mer200_per_20200208_011324-0.87029',
        'result_200208_0.872'
        ]

file = stra[0]
A = pd.read_csv(f'select/{file}.csv', header=None)
A.columns = ['ship', 'type']
for file in stra[1:]:
    B = pd.read_csv(f'select/{file}.csv', header=None)
    B.columns = ['ship', 'type']
    A = pd.merge(A, B, on='ship')


A['围网'] = A.apply(lambda x: sum(x == '围网'), axis=1)
A['拖网'] = A.apply(lambda x: sum(x == '拖网'), axis=1)
A['刺网'] = A.apply(lambda x: sum(x == '刺网'), axis=1)
A['label'] = A[['围网', '拖网', '刺网']].apply(lambda x: np.argmax(x), axis=1)
sub = A[['ship', 'label']]


now = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
date = now[:8]
file = f'res_ensemble_hyt_liz_{now}.csv'
sub.to_csv(f'select/{file}', index=None, header=None)
print(file)